package com.cc.cbdb.fragment;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;

import com.cc.cbdb.R;
import com.cc.cbdb.activity.AdvancedQueryActivity;
import com.cc.cbdb.activity.RelationQueryActivity;
import com.cc.cbdb.activity.SearchActivity;
import com.cc.cbdb.activity.X5WebViewActivity;
import com.cc.cbdb.common.constants.Constant;
import com.cc.cbdb.common.report.ReportHelper;

/**
 * A simple {@link Fragment} subclass.
 */
public class QueryFragment extends Fragment implements View.OnClickListener{

    private Button btn_nameQuery,btn_addressQuery,btn_officerQuery,btn_advancedQuery,btn_assosiationQuery;
    private Activity mActivity;

    @Override
    public void onStart() {
        mActivity = getActivity();
        initUI();
        super.onStart();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_query, container, false);
    }


    private void initUI() {
        btn_nameQuery = mActivity.findViewById(R.id.btn_nameQuery);
        btn_addressQuery = mActivity.findViewById(R.id.btn_addressQuery);
        btn_officerQuery = mActivity.findViewById(R.id.btn_officerQuery);
        btn_advancedQuery = mActivity.findViewById(R.id.btn_advancedQuery);
        btn_assosiationQuery = mActivity.findViewById(R.id.btn_assosiationQuery);

        btn_nameQuery.setOnClickListener(this);
        btn_addressQuery.setOnClickListener(this);
        btn_officerQuery.setOnClickListener(this);
        btn_advancedQuery.setOnClickListener(this);
        btn_assosiationQuery.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_nameQuery:
                Intent intent1 = new Intent(mActivity, SearchActivity.class);
                intent1.putExtra("title","人名查询");
                intent1.putExtra("tabName",Constant.SVTAB.SV_NAMES_TAB);
                startActivity(intent1);
                break;

            case R.id.btn_addressQuery:
                Intent intent2 = new Intent(mActivity, X5WebViewActivity.class);
                intent2.putExtra("title","地名查询");
                intent2.putExtra("url",Constant.DOMAIN_PROJECT+Constant.HTML.HTML_ADDRTREE);
                startActivity(intent2);
                break;

            case R.id.btn_officerQuery:
                Intent intent3 = new Intent(mActivity, X5WebViewActivity.class);
                intent3.putExtra("title","官名查询");
                intent3.putExtra("url",Constant.DOMAIN_PROJECT+Constant.HTML.HTML_OFFICETREE);
                startActivity(intent3);
                break;

            case R.id.btn_advancedQuery:
                startActivity(new Intent(mActivity, AdvancedQueryActivity.class));
                break;

            case R.id.btn_assosiationQuery:
                startActivity(new Intent(mActivity, RelationQueryActivity.class));
                break;
        }
    }
}
